<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>JS对象</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
</head>
<body>
    <div id="demo">

    </div>
    <script>
        // var obj = new Object();
        // var obj2 = obj;
        // obj.name = "aa";
        // obj.age = "12";
        // console.log(obj2);
        //
        // var obj3 = {
        //     a(){
        //       console.log("obj3的a方法");
        //     }
        // }
        // obj3.a();
        //
        //
        // function Person() {
        //     this.name = "a";
        //     this.age = 19;
        //     this.method1 = function(){
        //         console.log("method1");
        //     }
        // }
        // var person = new Person();
        // console.log(person);
        // person.method1();
        // console.log(person instanceof Person);
        function Person() {
            this.name = "a";
            this.age = 19;
            this.method1 = method;
        }
        function method(){
            console.log("method1");
        }
        Person.prototype.gender = "man";
        var person = new Person();
        console.log(person);
        person.method1();
        console.log(person.toString());
        //定义完就执行
        (function(){
           alert("定义完就执行");     
        })();
    </script>
</body>
</html>